#include "commoditywindow.h"
#include "ui_commoditywindow.h"
#include "customrelationaltablemodel.h"

#include <iostream>


using namespace std;

CommodityWindow::CommodityWindow(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::CommodityWindow)
{
    ui->setupUi(this);



    model = new CustomRelationalTableModel(ui->tableView);
    //model->setEditStrategy(QSqlTableModel::OnManualSubmit);
    model->setTable("wms_commodity");
    model->select();
    ui->tableView->setModel(model);
    ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
    connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(accept()));
}

CommodityWindow::~CommodityWindow()
{
    delete model;
    delete ui;
}


void CommodityWindow::on_newButton_clicked()
{
    model->insertRow(model->rowCount());
    //ui->tableView->edit(model->index(model->rowCount()-1,1));
}
